package com.manager.gen.module.controller.user;

import com.manager.commons.annotation.Module;
import com.manager.commons.annotation.Operation;
import com.manager.commons.base.DataGrid;
import com.manager.core.module.log.aop.TMLog;
import com.manager.core.web.json.AjaxJson;
import com.manager.gen.module.entity.user.GenFeedback;
import com.manager.gen.module.service.user.GenFeedbackReplyService;
import com.manager.gen.web.controller.AdminController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * GenFeedbackController
 * 意见反馈
 *
 * @author manager
 * @version 1.0
 */
@Controller()
@Module(parent = "user-manager", title = "待回复反馈",sort = 3,code = "/gen/feedback/reply")
public class ReplyWaitFeedbackController extends AdminController<GenFeedback> {
    private final String baseUrl = "/gen/feedback/reply";
    @Autowired
    private GenFeedbackReplyService _service;

    /**
     * 列表
     *
     * @return
     */
    @TMLog(type = "mvp", description = "待回复意见反馈列表页面")
    @RequestMapping(baseUrl+"/index")
    public ModelAndView index() {
        return getModelAndView(baseUrl + "/feedback-reply-index");
    }


    /**
     * 新增
     *
     * @return
     */
    @TMLog(type = "mvp", description = "回复意见反馈")
    @RequestMapping(baseUrl+"/edit")
    @Operation(title = "回复")
    public ModelAndView edit() {
        return getModelAndView(baseUrl + "/feedback-reply-edit", _service.findMap(getParams()));
    }


    /**
     * 分页
     *
     * @return
     */
    @TMLog(type = "rmp", description = "意见反馈列表分页[post]。")
    @RequestMapping(value = baseUrl+"/list")
    @Operation(title = "列表")
    public @ResponseBody DataGrid page() {
        return _service.queryPage(getParams());
    }

    /**
     * 保存
     *
     * @returna
     */
    @TMLog(type = "rmp", description = "保存意见反馈数据[post]。")
    @PostMapping(value = baseUrl+"/save")
    public @ResponseBody AjaxJson save() {
        try {
            return _service.save(getParams());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage(), e);
        }
        return new AjaxJson("异常错误，请稍后再试");
    }


    @Override
    public GenFeedback getModel() {
        return new GenFeedback();
    }

}
